package com.rwind.schema.controller;

import com.rwind.schema.service.UserService;
import org.codehaus.commons.compiler.CompileException;
import org.codehaus.janino.SimpleCompiler;
import org.springframework.beans.factory.annotation.Autowired;
//@RestController
public class DemoController {

    @Autowired
    private UserService userService;

    @Autowired
    private JaninoSpringIntegration janinoSpringIntegration;

   // @RequestMapping("/show")
    public String hello(String name) {
        try {
            Object result = janinoSpringIntegration.evaluateExpression("us.getUserInfo(name)",
                    new String[]{"us", "name"}, new Object[]{userService, name}, String.class);
            return String.valueOf(result);
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        //return janinoSpringIntegration.evaluateExpression("userService","getUserInfo('" + name + "')")
        return "sorry";
    }
}
